home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 128 12
/
q12.d81
/
t.zero page 12
< prev
next >
Wrap
Text File
|
2022-08-28
|
10KB
|
212 lines
ZERO PAGE: MOVING FROM THE C-64 TO THE C-128
By Barbara H. Schulak and Jon Mattson
If you have owned a C-64 and then upgraded to a C-128, you will
certainly appreciate BASIC 7.0's increased vocabulary, not to mention the
improved graphics and sprite tools. The architecture of each machine is
similar, especially in the case of the 40-column screen; however, some
things are different and/or not clearly explained in the various
publications about the C-128. As we discover these little "trade secrets",
we usually jot them down for future reference. Now we would like to pass
some of them along to you. They are in no particular order nor carry a
theme, but are merely 'ramblings'.
First, the function keys. They come with preset definitions, of
course, which may be changed by the KEY command. There will be times,
however, when you want to change them to the normal CHR$ values so that you
can use them in a program. One solution is to go KEY1,CHR$(131), etc. but
an easier method is to POKE 828,183. To restore the normal definitions,
POKE 828,173. Another problem is that the F1-F8 keys can be changed by
using KEY, but the HELP and SHIFT/RUN/STOP definitions are not so easy to
access. To change these definitions...
SYS 24812,,9,,,"DEFINITION"
SYS 24812,,8,,,"DEFINITION"
There are also a few more keys on the keyboard. How does one detect
these in a program? Location 211 is the shift key status flag but also
indicates if the Commodore, CTRL, ALT or CAPS LOCK key has been pressed.
Each bit corresponds to a key so that the values are additive:
SHIFT Bit 0 (1)
Commodore Bit 1 (2)
CONTROL Bit 2 (4)
ALT Bit 3 (8)
CAPS LOCK Bit 4 (16)
Therefore, the code to wait for the ALT key to be pressed would be...
10 IF PEEK(211)<>8 THEN 10
Likewise the ESC, TAB, HELP, LINEFEED, NO SCROLL, upper cursor keys and
keypad can be detected by PEEKing location 212. The appropriate values for
these can be found in most reference guides.
And what of the 40/80 display switch? To check the status of this key,
use...
X=PEEK(54533) AND 128
If X=0, the key is up (40-column); if X=128, then the switch is down
(80-column). Similarly, you can PEEK(215) to see if you are in 40-column
mode (0) or in 80-column mode (128).
You may have encountered a few difficulties with the CHAR command.
When trying to use the hires screen with the lower case font, simply
switching character sets does not work. The solution to this problem is to
include a CHR$(14) command in your string as follows:
CHAR,X,Y,CHR$(14)+A$
The CHAR command also does not function properly on the 80-column
screen if you move the start of BASIC to $4000 by using the usual
GRAPHIC1:GRAPHIC5 syntax (to use the underlying memory for ML modules or
graphics, for example). It prints to the hires screen instead, since that
is the screen the VIC chip is currently "watching". In fact, if you switch
your monitor to 40-columns while the computer still thinks it is using 80,
you will notice that the hires screen, not the text screen, is visible. The
solution to this is simple: GRAPHIC1:GRAPHIC0:GRAPHIC5 will point the VIC
chip in the right direction.
Of course, no discussion of the 128 would be complete without
mentioning the peculiarities of the 80-column screen. Here are a few
examples of things that we have learned...
1] To POKE a value to a VDC register: SYS 52684,value,register
2] To PEEK a VDC register: SYS 52698,,register:RREG A
3] To turn on the cursor: SYS 52684,192,10
4] To turn off the cursor: SYS 52684,160,10
5] To restore the normal Commodore character sets (after using a custom
font, for example): SYS 65378 (or 52748)
6] When altering color memory directly, the required values are not the
same as those used with the 40-column screen, nor are they the values
inaccurately listed in most reference sources (including the Programmer's
Reference Guide). The actual values are:
0 - Black 5 - Light Green 10 - Dark Purple
1 - Dark Grey 6 - Dark Cyan 11 - Light Purple
2 - Dark Blue 7 - Light Cyan 12 - Dark Yellow
3 - Light Blue 8 - Dark Red 13 - Light Yellow
4 - Dark Green 9 - Light Red 14 - Light Grey
15 - White
7] 'Color memory' is actually a misnomer on the 80-column screen: the
term 'attribute memory' is actually more correct. The reason for this is
that each byte of attribute memory uses the first four bits for color as
usual (see #6) but also uses the last four bits, as follows:
4 (16) - Blink
5 (32) - Underline
6 (64) - Reverse
7 (128) - Alternate set
Bit 7 is especially important, since it allows the VDC to display two
character sets on the screen at the same time, for a total of 512
characters. However...
8] The reverse attribute is NOT the same as reverse character mode.
Choosing the reverse attribute for a character does a literal inversion of
the shape in question rather than just replacing it with the character's
screen code + 128. An example should clarify this.
Normally, when you print a reversed 'A' to the screen, it has a screen
code of 129 (128 higher than the usual value of 1). If you alter the font
so that character number 129 looks like a bug, you will get a bug every time
you print a reversed 'A'. HOWEVER, if you use the reverse attribute (bit 6)
instead, you can make a normal 'A' look like a reversed 'A' and your bug
look like a reversed bug! If you think about this for a moment, you will
realize an important implication: by manipulating attribute memory directly
(for example, with CONTROL80's POST command), you can have revsersed
characters without using the second half of your font at all; instead, it
can be redefined in any way you choose. In effect, you have, not 512
characters to work with, but 1024 -- the usual two full characters sets of
256 each, plus the reversed versions of these!
By the way, point #2 brings up another interesting near-unknown about
the 128. Although many reference guides do not mention it, the 128 has
another new command called RREG. It is mainly for use with the SYS command
and machine language routines since it reads the A,X,Y and Status registers
(respectively) and puts them into variables. For example,
BANK 15:SYS 65517:RREG SW,WW,WH
allows you to determine the size of the current screen window. SW will
contain the full screen width, WW will contain the window width, and WH will
contain the window height.
Another tip for machine language programmers: JSR 65357 (or SYS 65357
in BASIC) works the same as the GO64 command, allowing you to enter C-64
mode. Remember that this is a one-way trip!
Finally, here are a few useful PEEKs and POKEs, along with their C-64
equivalents. Some of those already mentioned are included here again for
your convenience. Notice, in particular, that clearing the keyboard buffer
(POKE 208,0) does NOT clear any pending function keys. For this, you must
use POKE 209,0. This is also a good way to keep the buffer clear of
meaningless input from joystick #1: you have probably noticed that the fire
button acts as F8 and calls up the machine language monitor while the
function keys have their default definitions.
FUNCTION C-128 C-64
LIST: Disable POKE 775,139 POKE 775,191
Enable POKE 775,81 POKE 775,167
LIST Line #s: Disable POKE 24,37 POKE 22,35
Enable POKE 24,27 POKE 22,25
LOAD: Disable POKE 816,0 POKE 816,157
Enable POKE 816,108 POKE 816,165
SAVE: Disable POKE 818,180 POKE 819,246
Enable POKE 818,78 POKE 819,245
RUN/STOP Key: Disable POKE 808,100 POKE 808,239
Enable POKE 808,110 POKE 808,237
RESTORE Key: Disable